package cn.iocoder.yudao.module.eval.dal.mysql.candidate;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.eval.controller.admin.candidate.vo.EvalCandidateMaterialPageReqVO;
import cn.iocoder.yudao.module.eval.dal.dataobject.candidate.EvalCandidateMaterialDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 参评人员材料管理 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface EvalCandidateMaterialMapper extends BaseMapperX<EvalCandidateMaterialDO> {

    default PageResult<EvalCandidateMaterialDO> selectPage(EvalCandidateMaterialPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EvalCandidateMaterialDO>()
                .eqIfPresent(EvalCandidateMaterialDO::getCandidateInfoId, reqVO.getCandidateInfoId())
                .eqIfPresent(EvalCandidateMaterialDO::getMaterialType, reqVO.getMaterialType())
                .likeIfPresent(EvalCandidateMaterialDO::getMaterialName, reqVO.getMaterialName())
                .eqIfPresent(EvalCandidateMaterialDO::getAuditStatus, reqVO.getAuditStatus())
                .eqIfPresent(EvalCandidateMaterialDO::getIsRequired, reqVO.getIsRequired())
                .betweenIfPresent(EvalCandidateMaterialDO::getUploadTime, reqVO.getUploadTime())
                .betweenIfPresent(EvalCandidateMaterialDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EvalCandidateMaterialDO::getId));
    }

    default List<EvalCandidateMaterialDO> selectListByCandidateInfoId(Long candidateInfoId) {
        return selectList(EvalCandidateMaterialDO::getCandidateInfoId, candidateInfoId);
    }

    default List<EvalCandidateMaterialDO> selectListByMaterialType(Integer materialType) {
        return selectList(EvalCandidateMaterialDO::getMaterialType, materialType);
    }

    default List<EvalCandidateMaterialDO> selectListByAuditStatus(Integer auditStatus) {
        return selectList(EvalCandidateMaterialDO::getAuditStatus, auditStatus);
    }

    default List<EvalCandidateMaterialDO> selectListByIsRequired(Boolean isRequired) {
        return selectList(EvalCandidateMaterialDO::getIsRequired, isRequired);
    }

    default List<EvalCandidateMaterialDO> selectListByCandidateInfoIdAndMaterialType(Long candidateInfoId, Integer materialType) {
        return selectList(new LambdaQueryWrapperX<EvalCandidateMaterialDO>()
                .eq(EvalCandidateMaterialDO::getCandidateInfoId, candidateInfoId)
                .eq(EvalCandidateMaterialDO::getMaterialType, materialType));
    }

    default List<EvalCandidateMaterialDO> selectListByCandidateInfoIdAndIsRequired(Long candidateInfoId, Boolean isRequired) {
        return selectList(new LambdaQueryWrapperX<EvalCandidateMaterialDO>()
                .eq(EvalCandidateMaterialDO::getCandidateInfoId, candidateInfoId)
                .eq(EvalCandidateMaterialDO::getIsRequired, isRequired));
    }

    default List<EvalCandidateMaterialDO> selectList(EvalCandidateMaterialPageReqVO exportReqVO) {
        return selectList(new LambdaQueryWrapperX<EvalCandidateMaterialDO>()
                .eqIfPresent(EvalCandidateMaterialDO::getCandidateInfoId, exportReqVO.getCandidateInfoId())
                .eqIfPresent(EvalCandidateMaterialDO::getMaterialType, exportReqVO.getMaterialType())
                .likeIfPresent(EvalCandidateMaterialDO::getMaterialName, exportReqVO.getMaterialName())
                .eqIfPresent(EvalCandidateMaterialDO::getAuditStatus, exportReqVO.getAuditStatus())
                .eqIfPresent(EvalCandidateMaterialDO::getIsRequired, exportReqVO.getIsRequired())
                .betweenIfPresent(EvalCandidateMaterialDO::getUploadTime, exportReqVO.getUploadTime())
                .betweenIfPresent(EvalCandidateMaterialDO::getCreateTime, exportReqVO.getCreateTime())
                .orderByDesc(EvalCandidateMaterialDO::getId));
    }

}
